package org.foxas.keymanager
{
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	
	import org.foxas.display.FSprite;

	public class KMstage extends FSprite
	{
		public function KMstage()
		{
			super();
		}
		override protected function onAddedStage(_e:Event):void{
			super.onAddedStage(_e);
			this.stage.addEventListener(KeyboardEvent.KEY_DOWN,onKeyDo);
			this.stage.addEventListener(KeyboardEvent.KEY_UP,onKeyUn);
		}
		override protected function onRemovedStage(_e:Event):void{
			super.onRemovedStage(_e);
			this.stage.removeEventListener(KeyboardEvent.KEY_DOWN,onKeyDo);
			this.stage.removeEventListener(KeyboardEvent.KEY_UP,onKeyUn);
			this.removeEventListener(Event.ADDED_TO_STAGE,onAddedStage);
		}
		private function onKeyDo(_e:KeyboardEvent):void{
//		trace(_e.keyLocation,_e.charCode,_e.keyCode,_e.ctrlKey,_e.shiftKey,_e.altKey,_e.toString());
			KM.onKeyDown(_e);
		}
		private function onKeyUn(_e:KeyboardEvent):void{
			KM.onKeyUp(_e);
		}
	}
}